﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="FastSpring.Core.Model.Role,FastSpring.Net.Core" table="Sys_Role" lazy="false">
    <id name="RID" column="RID" type="Int32">
      <generator class="native" />
    </id>
    <property name="Rcode" column="Rcode"/>
    <property name="Rname" column="Rname"/>
    <property name="Description" column="Description"/>
    <property name="IsActive" column="IsActive"/>
    <bag name="RoleFunctions" cascade="none" inverse="false" lazy="false" order-by="RFID">
      <key column="RID"/>
      <one-to-many class="FastSpring.Core.Model.RoleFunction,FastSpring.Net.Core" />
    </bag>
  </class>
  <class name="FastSpring.Core.Model.RoleFunction,FastSpring.Net.Core" table="Sys_RoleFunction" lazy="false">
    <id name="RFID" column="RFID" type="Int32">
      <generator class="native" />
    </id>
    <many-to-one name="Role" 
      class="FastSpring.Core.Model.Role,FastSpring.Net.Core" 
      cascade="none" 
      column="RID" 
      not-null="true"/>
    <many-to-one name="Function" 
      class="FastSpring.Core.Model.Function,FastSpring.Net.Core" 
      cascade="none" 
      column="FID" 
      not-null="true"/>
  </class>
  <query name="RoleList">
    <![CDATA[Select role.Rname,role.RID from Role role ORDER BY role.Rname]]>
  </query>
  <query name="GetAllRoles">
    <![CDATA[from Role role WHERE role.IsActive=1]]>
  </query>
  <query name="GetRoleOfRID">
    <![CDATA[from Role role WHERE role.IsActive=1 AND role.RID=:RID]]>
  </query>  
  <!-- 删除角色时查询此角色下是否有角色权限设置 -->
  <query name="GetRoleFunctionsOfRID">
    <![CDATA[from RoleFunction roleFunction WHERE roleFunction.Role.RID=:ParentID]]>
  </query>
  <!--<query name="GetInventoryByItemProperty">
    <![CDATA[
        select new com.vtradex.wms.model.inventory.InventoryReport(inventory1.itemInventory.itemKey.item.company.name,
                    inventory1.itemInventory.itemKey.item.code,
                    inventory1.itemInventory.itemKey.item.name,
                    inventory1.itemInventory.itemKey.warehouse.name,
                    sum(inventory1.quantity),
                    inventory1.itemInventory.itemKey.itemProperties.itemStatus)
              from com.vtradex.wms.model.inventory.Inventory as inventory1
              where inventory1.itemInventory.itemKey.item.company in (:company)
                    and inventory1.itemInventory.itemKey.warehouse in (:warehouse)
                    group by inventory1.itemInventory.itemKey.item.company.name,
                    inventory1.itemInventory.itemKey.item.code,
                    inventory1.itemInventory.itemKey.item.name,
                    inventory1.itemInventory.itemKey.warehouse.name,
                    inventory1.itemInventory.itemKey.itemProperties.itemStatus
                    ]]>
  </query>-->
</hibernate-mapping>
